﻿<?php

$obj=new mysql($config);

if(!empty($_POST)){
    $id=$_POST['id'];
    $arr['name']=$_POST['name'];
    $arr['pid']=$_POST['pid'];
    $row=$obj->update($arr,array('id'=>$id),'cate');
    if($row>0){
         echo "<script>alert('更新成功');</script>";
    }else{
         echo "<script>alert('更新失败');</script>";
    }
}




$id=$_GET['id'];
$sql="select * from `cate` where id=$id";
$one=$obj->getOne($sql);
$data=getPrent($obj,$id);

function getPrent($obj,$pid){
            static $arr=array();
            $sql="select * from `cate` where id=$pid";
            $date=$obj->getOne($sql);
                

            if($pid!=0){    
                $id=$date['pid'];
                $sql="select * from `cate` where pid=$id";
                $arr[$date['id']]=$obj->getCondition($sql);        
                  getPrent($obj,$id);
            }
 

            return  array_reverse($arr,true);
}









require_once (VIEW_PATH.'admin/layout.html');

